<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="messageBtn">弹出对话框</button>
</body>
<script>
    const { dialog } = require('@electron/remote')
    var messageBtn = document.getElementById('messageBtn')

    messageBtn.onclick=function(){
        dialog.showMessageBox({
            type:'warning',
            title:'危险警告',
            message:'确定丢弃该修改？',
            buttons:['取消','确定'],
            defaultId:0
        }).then(result=>{// 回调函数
            // result是一个对象
            // 点击了按钮之后，result.response返回的是点击按钮的索引
            console.log(result)
        })
    }
</script>
</html>